export const getOption = (data: any, times: string[]) => {
  let names = data.map((v: any) => v.name);
  const option: echarts.EChartsOption = {
    tooltip: {
      trigger: "axis",
    },

    legend: {
      show: true,
      data: names,
      bottom: 0,

      textStyle: {
        fontSize: 12,
        color: "#000",

        padding: [0, 0, 0, 5],
      },
      padding: [0, 10],

      inactiveColor: "#666666", // This sets the color for inactive legend items

      type: "scroll",
    },
    grid: {
      top: 30,
      left: 40,
      bottom: 50,
      right: 30,
    },
    xAxis: {
      type: "category",
      boundaryGap: false,
      axisLabel: {
        fontSize: 12,
        formatter: (value: string) => value, // Format to show time directly
      },
      data: times,
    },
    yAxis: [
      {
        type: "value",
        // name: "Power (kW)",
        position: "left",
        minInterval: 1, // 设置最小间隔为20

        axisLabel: {
          fontSize: 12,
        },
        splitLine: {
          show: true,
        },
      },
    ],
    series: data,
  };
  return option;
};
